package com.sun.clients.service.impl;

import com.sun.clients.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class MessageServiceImpl implements MessageService {

    @Override
    public void saveMessage(ConsumerRecords<String, String> records) {
        long startTime = System.currentTimeMillis();
        for (final ConsumerRecord<String, String> record : records) {
            log.info("消费的消息：record = {}", record);
        }
        long endTime = System.currentTimeMillis();
        log.info("消息保存完成！消耗时间：{}ms", (endTime-startTime));
    }

}
